--[[------------------------------------------------------------------------------------------------------------------ Переключение боевых схем --------------------------------------------------------------------------------------------------------------------]] function set_combat_type(npc, actor, t) if t == nil then return end -- это нужно для функций в xr_conditions.script local storage = db.storage[npc:id()] storage.enemy = npc:best_enemy() local script_combat_type = nil if t.combat_type ~= nil then script_combat_type = xr_logic.pick_section_from_condlist(actor, npc, t.combat_type.condlist) if script_combat_type == "nil" then script_combat_type = nil end end storage.script_combat_type = script_combat_type t.script_combat_type = script_combat_type end ---------------------------------------------------------------------------------------------------------------------- -- Эвалуатор переключения между скриптовым и движковым боем -- false - engine combat, true - script combat ---------------------------------------------------------------------------------------------------------------------- class "evaluator_check_combat" (property_evaluator) function evaluator_check_combat:__init(name, storage) super (nil, name) self.st = storage end function evaluator_check_combat:evaluate() if not (self.object:alive()) then return false end local st = self.st if st.enabled and self.object:best_enemy() then local actor = db.actor if not actor then return false end return st.script_combat_type ~= nil end return false end ---------------------------------------------------------------------------------------------------------------------- -- Дублирующий эвалуатор врагов для планировщика скриптового боя ---------------------------------------------------------------------------------------------------------------------- class "evaluator_enemy" (property_evaluator) function evaluator_enemy:__init(name) super (nil, name) end function evaluator_enemy:evaluate() return self.object:best_enemy() ~= nil end ---------------------------------------------------------------------------------------------------------------------- -- binder ---------------------------------------------------------------------------------------------------------------------- function setup_generic_scheme(npc,ini,scheme,section,stype,temp) temp.section = ini:r_string_ex(section,"on_combat") or section temp.is_zombied = character_community(npc) == "zombied" local st = xr_logic.assign_storage_and_bind(npc,ini,scheme,temp.section,temp) if (not temp.disabled) then st.logic = xr_logic.cfg_get_switch_conditions(ini,temp.section,npc) st.enabled = true st.combat_type = xr_logic.cfg_get_condlist(ini, temp.section, "combat_type", npc) -- зомбированные сражаются по умолчанию на зомбированной боевой схеме if not st.combat_type and temp.is_zombied then st.combat_type = { condlist = xr_logic.parse_condlist(npc, temp.section, "", "zombied") } end if st.combat_type then set_combat_type( npc, db.actor, st ) end end end function add_to_binder(npc,ini,scheme,section,storage,temp) if not npc then return end local manager = npc:motivation_action_manager() if not manager then return end if (temp.section or temp.is_zombied) then manager:add_evaluator(xr_evaluators_id.script_combat,evaluator_check_combat("script_combat",storage)) --printf("ACTION_ALIFE_ID(xr_combat.add_to_binder): " .. tostring(stalker_ids.action_combat_planner)) local action = manager:action(stalker_ids.action_combat_planner) if not action then return end action:add_precondition(world_property(xr_evaluators_id.script_combat, false)) xr_combat_zombied.add_to_binder(npc,ini,storage,manager,temp) xr_combat_camper.add_to_binder(npc,ini,storage,manager,temp) xr_combat_monolith.add_to_binder(npc,ini,storage,manager,temp) else manager:add_evaluator(xr_evaluators_id.script_combat,property_evaluator_const(false)) temp.needs_configured = false end end function disable_scheme(npc,scheme,stype) local st = db.storage[npc:id()]["combat"] if st then st.enabled = false end end